const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  module: {
    rules: [
      {
        test: require.resolve('./frameworkCode/resources/js/notModuleJsFiles/big/big.js'),
        use: ['script-loader']
      },
      {
        test: require.resolve('./frameworkCode/resources/js/notModuleJsFiles/scrollbar/perfect-scrollbar.min.js'),
        use: ['script-loader']
      },
      {
        test: require.resolve('./frameworkCode/resources/js/module/chart/Chart.js'),
        use: ['script-loader']
      },
      {
        test: require.resolve('./frameworkCode/resources/js/module/file/FileSaver.js'),
        use: ['script-loader']
      },
      {
        test: require.resolve('./frameworkCode/resources/js/module/file/view/pdf.js'),
        use: ['script-loader']
      },
      {
        test: require.resolve('./frameworkCode/resources/js/module/file/view/pdf.worker.js'),
        use: ['script-loader']
      },
      {
        test: /\.html$/,
        use: [
          {
            loader: 'html-loader',
            options: {
              minimize: false
            }
          }
        ]
      },
      {
        test: /\.js$/,
        loader: 'babel-loader?compact=false',
        exclude: /node_modules/
      },
      {
        test: /\.(jpg|png|gif|jpeg|bmp)$/,
        use: {
          loader: 'file-loader',
          options: {
            name:'[name].[ext]',
            outputPath:'images/'
          }
        }
      },
      {
        test: /\.(woff|woff2|svg|ttf|eot)$/,
        use: {
          loader: 'file-loader',
          options: {
            name:'[name].[ext]',
            outputPath:'fonts/'
          }
        }
      }
    ]
  },
  plugins: [
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify("production") }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      chunks: ['main', 'AngularJs']
    })
  ]
};



